package com.tao.YanMoDesignPattern.singleton.pattern.case1_Origin;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Author Mi_Tao
 * @Date 2023/7/23
 * @Description
 * @Version 1.0
 **/
public class AppConfig {

    private String parameterA;
    private String parameterB;

    public AppConfig(){
        readConfig();
    }

    private void readConfig() {
        Properties properties = new Properties();
        InputStream in = null;

        try {
            in = AppConfig.class.getResourceAsStream("/Appconfig.properties");
            properties.load(in);
            // 把配置文件中的内容读出来设置到属性上
            this.parameterA = properties.getProperty("parameterA");
            this.parameterB = properties.getProperty("parameterB");
        } catch (IOException e) {
            System.out.println("转载配置文件出错了！");
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public String getParameterA() {
        return parameterA;
    }

    public String getParameterB() {
        return parameterB;
    }
}
